package com.hbxy.favorite.controller;
import com.hbxy.favorite.domain.User;
import com.hbxy.favorite.resault.ResponseBo;
import com.hbxy.favorite.utils.JWTUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.HashMap;
import java.util.Map;

public class BaseController {

    private Logger log = LoggerFactory.getLogger(this.getClass());

 public ResponseBo judgeLogin(User user, String password){

     Map<String,Object> map = new HashMap<>();
     if(user != null){
         if(!password.equals(user.getPassWord())){
             log.info("获取的后台的密码："+user.getPassWord());
             log.info("输入的密码:"+password);
             return ResponseBo.error("密码错误！");
         }
         else{
             map.put("user", user);
             map.put("token", JWTUtil.createToken(user.getUserName())); //jwt生成token
             return ResponseBo.ok(map);
         }
     }

     return null;
 }

}


